import request from "@/utils/request";

// 获取值班排班列表
export function getDutySchedules(params) {
  return request({
    url: "/dutySchedule/getDutyList",
    method: "get",
    params,
  });
}

// 获取值班排班详情
export function getDutyScheduleById(id) {
  return request({
    url: `/duty-schedules/${id}`,
    method: "get",
  });
}

// 获取护士的排班列表
export function getDutySchedulesByNurseId(nurseId, params) {
  return request({
    url: `/duty-schedules/nurse/${nurseId}`,
    method: "get",
    params,
  });
}

// 获取日期范围内的排班
export function getDutySchedulesByDateRange(startDate, endDate) {
  return request({
    url: "/duty-schedules/date-range",
    method: "get",
    params: { startDate, endDate },
  });
}

// 创建值班排班
export function createDutySchedule(data) {
  return request({
    url: "/dutySchedule/add",
    method: "post",
    data,
  });
}

// 更新值班排班
export function updateDutySchedule(id, data) {
  return request({
    url: `/duty-schedules/${id}`,
    method: "put",
    data,
  });
}

// 删除值班排班
export function deleteDutySchedule(id) {
  return request({
    url: `/dutySchedule/delete`,
    method: "delete",
    params: {
      id,
    },
  });
}

// 更新值班排班状态
export function updateDutyScheduleStatus(id, status) {
  return request({
    url: `/dutySchedule/editStatus`,
    method: "get",
    params: { id, status },
  });
}

// 生成值班排班
export function generateDutySchedule(data) {
  return request({
    url: "/duty-schedules/generate",
    method: "post",
    data,
  });
}

// 获取值班记录列表
export function getDutyRecords(params) {
  return request({
    url: "/duty-records",
    method: "get",
    params,
  });
}

// 获取值班记录详情
export function getDutyRecordById(id) {
  return request({
    url: `/duty-records/${id}`,
    method: "get",
  });
}

// 获取护士的值班记录
export function getDutyRecordsByNurseId(nurseId, params) {
  return request({
    url: `/duty-records/nurse/${nurseId}`,
    method: "get",
    params,
  });
}

// 获取排班对应的值班记录
export function getDutyRecordByScheduleId(scheduleId) {
  return request({
    url: `/duty-records/schedule/${scheduleId}`,
    method: "get",
  });
}

// 创建值班记录
export function createDutyRecord(data) {
  return request({
    url: "/duty-records",
    method: "post",
    data,
  });
}

// 更新值班记录
export function updateDutyRecord(id, data) {
  return request({
    url: `/duty-records/${id}`,
    method: "put",
    data,
  });
}

// 删除值班记录
export function deleteDutyRecord(id) {
  return request({
    url: `/duty-records/${id}`,
    method: "delete",
  });
}
